package com.yinNuo.collectWool.quartz.controller;

import com.yinNuo.collectWool.core.Response;
import com.yinNuo.collectWool.quartz.entity.SysJobLog;
import com.yinNuo.collectWool.quartz.service.ISysJobLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * create by: yinNuo
 * create at: 2022/1/8 下午7:09
 * description: 调度日志操作处理
 */
@RestController
@RequestMapping("/quartz/jobLog")
public class SysJobLogController {
    @Autowired
    private ISysJobLogService jobLogService;

    /**
     * 查询定时任务调度日志列表
     */
    @GetMapping("/list")
    public Response list(SysJobLog sysJobLog) {
        //startPage();
        List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
        return Response.ok(list);
    }

    /**
     * 根据调度编号获取详细信息
     */
    @GetMapping(value = "/{configId}")
    public Response getInfo(@PathVariable Long jobLogId) {
        return Response.ok(jobLogService.selectJobLogById(jobLogId));
    }


    /**
     * 删除定时任务调度日志
     */
    @DeleteMapping("/{jobLogIds}")
    public Response remove(@PathVariable Long[] jobLogIds) {
        return Response.ok(jobLogService.deleteJobLogByIds(jobLogIds));
    }

    /**
     * 清空定时任务调度日志
     */
    @DeleteMapping("/clean")
    public Response clean() {
        jobLogService.cleanJobLog();
        return Response.ok();
    }
}
